package team2.arsystem.GUI;

import java.util.ArrayList;

import team2.arsystem.Controller.ApplicationController;
import team2.arsystem.Utilities.CommandConstants;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class ViewDebitReminders extends Activity {

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		ScrollView sv = new ScrollView(this);
		LinearLayout ll = new LinearLayout(this);
		ll.setOrientation(LinearLayout.VERTICAL);
		sv.addView(ll);
				
		ArrayList<ArrayList<String>> debitReminders= ApplicationController.getApplicationController().passCommandAndFetchMultipleResult(CommandConstants.getDebitReminders);
		
		ArrayList<String> desc = debitReminders.get(0);
		ArrayList<String> debitTxDate = debitReminders.get(1);
		ArrayList<String> debitRemDate = debitReminders.get(2);
		ArrayList<String> amount = debitReminders.get(3);
		ArrayList<String> membersList = debitReminders.get(4);
		
		ArrayList<TextView> tv = new ArrayList<TextView>();
	
		for(int i=0;i<desc.size();i++)
		{
			String text = "\n Amount : "+amount.get(i)+"\n Description : "+desc.get(i)+"\n Transaction Date : "+debitTxDate.get(i)+"\n Reminder Date : "+debitRemDate.get(i)+"\n Members : "+membersList.get(i)+"\n\n";
			tv.add(new TextView(this));
			tv.get(i).setText(text);
		}
	
		for(int i=0;i<desc.size();i++)
		{
			ll.addView(tv.get(i));
		}
		
		Button goBackButton = new Button(this);
		goBackButton.setText("Go Back");
		ll.addView(goBackButton);
		
		this.setContentView(sv);
		
		goBackButton.setOnClickListener(new OnClickListener() {
			
        	public void onClick(View v) {
        		
        	  	try
                 	{
                        	 Class menuScreen = Class.forName("team2.arsystem.GUI."+"MenuScreen");
                    		 Intent myIntent = new Intent(ViewDebitReminders.this,menuScreen);
                    		 startActivity(myIntent);
                        	}
                        	catch(Exception e)
                        	{
                    			 e.printStackTrace();
                    		 }
                    		 
                        }
        	
                    });
        		    
		
	}
}
